/**
 * Created by Administrator on 2017/4/21 0021.
 */
var Page0={
    create:function () {
        var page={};

        page.ui=new PIXI.DisplayObjectContainer();

        var bg=new PIXI.Graphics();
        bg.beginFill(0xffffff,1);
        bg.drawRect(0,0,1136,740);
        bg.endFill();
        page.ui.addChild(bg);

        var i0=Easy.CreateSprite('assets/images/p0_i0.png',240,106,0.5,0.5,1);
        page.ui.addChild(i0);
        var mask_i0=new PIXI.Graphics();
        mask_i0.beginFill();
        mask_i0.drawRect(-734/2,-492/2,734,492);
        mask_i0.endFill();
        mask_i0.x=967;
        mask_i0.y=-100;
        page.ui.addChild(mask_i0);
        i0.mask=mask_i0;

        var i1=Easy.CreateSprite('assets/images/p0_i1.png',542,281,0.5,0.5,1);
        page.ui.addChild(i1);
        var mask_i1=new PIXI.Graphics();
        mask_i1.beginFill();
        mask_i1.drawRect(-1136/2,-640/2,1136,640);
        mask_i1.endFill();
        mask_i1.x=-570;
        mask_i1.y=864;
        page.ui.addChild(mask_i1);
        i1.mask=mask_i1;

        var i2=Easy.CreateSprite('assets/images/p0_i2.png',805,490,0.5,0.5,1);
        page.ui.addChild(i2);
        var mask_i2=new PIXI.Graphics();
        mask_i2.beginFill();
        mask_i2.drawRect(-977/2,-654/2,977,654);
        mask_i2.endFill();
        mask_i2.x=-168;
        mask_i2.y=688;
        page.ui.addChild(mask_i2);
        i2.mask=mask_i2;

        var m0=Easy.CreateSprite('assets/images/p0_m0.png',568,311,0.5,0.5,0);
        page.ui.addChild(m0);
        var m1=Easy.CreateSprite('assets/images/p0_m1.png',830,350,0.5,0.5,0);
        page.ui.addChild(m1);
        var m2=Easy.CreateSprite('assets/images/p0_m2.png',194,301,0.5,0.5,0);
        page.ui.addChild(m2);

        var time0;
        var time1;
        var time2;

        page.In=function () {
            time0=setTimeout(
                function () {
                    maskIn();
                    m0.scale.x=m0.scale.y=2.5;
                    m0.alpha=0;
                    m0.y=311;
                    TweenMax.to(m0,0.5,{delay:1,alpha:1,y:370,ease:Cubic.easeInOut});
                    TweenMax.to(m0.scale,0.5,{delay:1,x:1,y:1,ease:Cubic.easeInOut});
                    TweenMax.to(m0.scale,1.5,{delay:1.5,x:0.9,y:0.9,ease:Linear.easeNone});
                    TweenMax.to(m0,0.5,{delay:2.5,alpha:0,ease:Cubic.easeIn});
                },200);


            time1=setTimeout(function () {
                maskIn();
                m1.alpha=0;
                m1.x=1253;
                TweenMax.to(m1,0.5,{delay:1-1,x:830,alpha:1,ease:Cubic.easeInOut});
                TweenMax.to(m1,1.5,{delay:1.5-1,x:830-50,ease:Linear.easeNone});
                TweenMax.to(m1,0.5,{delay:2.5-1,x:830-350,alpha:0,ease:Cubic.easeIn});
            },3200);

            time2=setTimeout(function () {
                maskIn();
                m2.alpha=0;
                m2.x=-346;
                m2.y=770;
                m2.rotation=0;
                TweenMax.to(m2,0.5,{delay:1-1,x:184,y:321,alpha:1,ease:Cubic.easeInOut,onComplete:function () {
                    TweenMax.to(m2,0.7,{x:184+10,y:321-10,repeat:-1,yoyo:true,ease:Cubic.easeInOut});
                }});

            },5200);
        }
        page.Out=function () {
            console.log('out!!!')
            clearTimeout(time0)
            clearTimeout(time1)
            clearTimeout(time2)
            TweenMax.killTweensOf(m0);
            TweenMax.killTweensOf(m1);
            TweenMax.killTweensOf(m2);
            TweenMax.killTweensOf(i0);
            TweenMax.killTweensOf(i1);
            TweenMax.killTweensOf(i2);
            setTimeout(function () {
                mask_i0.x=967;mask_i0.y=-100;
                mask_i1.x=-570;mask_i1.y=864;
                mask_i2.x=-236;mask_i2.y=744;
                m0.alpha=0;
                m1.alpha=0;
                m2.alpha=0;
            },200)

        }
        function maskIn()
        {
            mask_i0.x=967;mask_i0.y=-100;
            mask_i1.x=-570;mask_i1.y=864;
            mask_i2.x=-236;mask_i2.y=744;

            TweenMax.to(mask_i0,0.6,{delay:0.0,x:223,y:115,ease:Cubic.easeInOut});
            TweenMax.to(mask_i2,0.6,{delay:0.3,x:820,y:431,ease:Cubic.easeInOut});
            TweenMax.to(mask_i1,0.8,{delay:0.5,x:568,y:257,ease:Cubic.easeInOut});
        }

        return page;
    }
}